﻿using System.Reflection;
using NUnit.Framework;
using ContentRenderingApi;
using System.IO;
using System.Text;
using System.Collections.Generic;

namespace ContentRenderingApiSystemTest.TestFixture
{
    [TestFixture]
    public class RenderLargeOutputTestFixture
    {
        [Test]
        public void Test()
        {
            StringBuilder stringBuilder = new StringBuilder(1000008);

            stringBuilder.Append("[value:");

            for (int index = 0; index < 1000000; index++)
            {
                stringBuilder.Append("0");
            }

            stringBuilder.Append("]");

            List<string> values = new List<string>();

            for (int index = 0; index < 1000; index++)
            {
                values.Add("");
            }

            MemoryTemplate template = new MemoryTemplate("Template");

            // add the 1M template
            template.AddTemplate("Template", stringBuilder.ToString());

            // add the 1000 data objects
            template.AddNamedParameter("value", values);

            // if the data was stored in memory like the string builder then this would consume 1G of memory
            template.Render(Stream.Null, Encoding.Default);
        }
    }
}
